<%@ page contentType="text/html;charset=UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <%@ include file="/common/plateform/common-js.jsp"%>
  <%@ include file="/common/plateform/common-css.jsp"%>
  <title>模板标签定义</title>
  <!-- Tell the browser to be responsive to screen width -->
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
</head>
<style type="text/css">
body{
       word-wrap:break-word;
       word-break:keep-all;
       overflow:hidden;
}

</style>

<!-- 以下是body主体内容的模块区域 -->
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">

  <!-- top start -->
  <%@include file="/common/plateform/top.jsp" %>
  <!-- top end -->
  <!-- left start -->
  <%@include file="/common/plateform/left.jsp" %>
  <!-- left end-->

  <div class="content-wrapper">
    <!-- Main start -->
	<section class="content">
      <div class="row">
        <div class="col-xs-12">
        
          <!------搜索  start ------->
          <form id="searchForm" class="form-horizontal">
				<input type="hidden" name="doCode" value="dymicSql"/>
				<input type="hidden" name="pageName" value="sysTemplateInfo-list">
				<input type="hidden" name="formName" value="searchForm">
				<input type="hidden" name="sysTemplateInfo.w_templateId" value="${param.templateId}">
				<input type="hidden" name="orderBy" value="sysTemplateInfo.tab_no">
				<input type="hidden" name="sysTemplateInfo.w_delStatus" value="F">
			  </form>
	     <!------- 搜索 end -------->
           
        <!------- 列表 start -------->
          <div class="box box-success">
            <!--列表title  start --> 
	          <div class="box-header with-border">
                 <h3 class="box-title"><i class="fa fa-user"></i> 模板标签列表 
                 　　　              <button  onclick="toAdd();" class="btn btn-success" type="button"><i class="fa fa-plus-circle"></i> 增加标签 </button>
                 </h3>
                 <div class="box-tools pull-right">
	                 　　　　　　　　<button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i>
	                </button>
	                <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>
                 </div>
              </div>
            <!--列表title  end --> 
              <div class="box-body">
                <table id="dataList" class="table table-bordered table-hover" >
                <thead class="bg-success">
                <tr>
                        <th>编号</th>
                        <th>标签名称</th>
                        <th>行列（每行栅格数）</th>
                  		<th>操作</th>
                </tr>
                </thead>
                <tbody id="dataList-body">
                </tbody>
              </table>
              <center>
    	  		<ul id="dataList-page"></ul>
              </center>
            </div>
           </div>
        <!------- 列表 end -------->
        </div>
      </div>
    </section>
    <!-- Main end -->
  </div>
  <!-- /.content-wrapper -->
  <!-- foot start -->
  <%@include file="/common/plateform/foot.jsp" %>
  <!-- foot start -->
  
<div class="modal fade" id="my_modal_add" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							×
						</button>
						<h4 class="modal-title">
							<font color="red">信息添加</font> 
						</h4>
					</div>
					<div class="modal-body">
						<form class="form-horizontal" role="form" id="addForm">
							<input type="hidden" name="doCode" value="dymicSql"/>
							<input type="hidden" name="pageName"  value="sysTemplateInfo-list">
							<input type="hidden" name="formName"  value="addForm">
							<input type="hidden" name="sysTemplateInfo.templateId" value="${param.templateId}">
							<input type="hidden" name="sysTemplateInfo.delStatus" value="F">
							<input type="hidden" id="formToken" name="formToken" >
					        <div class="box-body" id="submitFormData">
					          <!-- Custom Tabs -->
					          <div class="nav-tabs-custom">
					            <div class="tab-content">
					              <div class="tab-pane active" id="tab_1">
					              
					                <div class="form-group">
						                  <label class="col-sm-3 control-label" >标签编号</label>
						                  <div class="col-sm-8">
						                		<input type="text" name="sysTemplateInfo.tabNo" class="form-control clean" required placeholder="必填项,数字" />
						                  </div>
						             </div>
							        
							        <div class="form-group">
						                  <label class="col-sm-3 control-label" >标签名称</label>
						                  <div class="col-sm-8">
						                		<input type="text" name="sysTemplateInfo.tabName" class="form-control clean" required placeholder="必填项，中文名称" />
						                  </div>
							        </div>
							        
							        <div class="form-group">
						                  <label class="col-sm-3 control-label" >每行栅格</label>
						                  <div class="col-sm-8">
						                		<input type="text" name="sysTemplateInfo.colNum" class="form-control" required placeholder="如：数字5或10" value="10"/>
						                </div>
							        </div>
							        
							        <!-- 
					                <div class="form-group">
						                  <label class="col-sm-2 control-label" >实体名</label>
						                  <div class="col-sm-8">
							                  <input type="text" id="addForm_objName" name="sysTemplateInfo.objName" class="form-control clean " readonly="readonly" required placeholder="请点击右侧按钮添加" value=""/>
						                  </div>
						                  <div class="col-sm-2">
						                	<button type="button" class="btn btn-success btn-sm" onclick="addTabObj('addForm_objName');"><i class="fa fa-plus-circle"></i> 添加实体对象</button>
						                  </div>
							        </div>
							        
							        
					                <div class="form-group">
						                  <label class="col-sm-2 control-label" >每行栅格</label>
						                  <div class="col-sm-4">
						                		<input type="text" name="sysTemplateInfo.colNum" class="form-control" required placeholder="如：5或者10" value="10"/>
						                </div>
						                <label class="col-sm-2 control-label" >工程名</label>
					                  		<div class="col-sm-4">
											<input type="text" name="sysTemplateInfo.projectName" value="${param.projectName}" readonly="readonly" class="form-control" required placeholder="必填项" />
					                  	  </div>
							        </div>
					                <div class="form-group">
						                  <label class="col-sm-2 control-label" >模板名称</label>
						                  <div class="col-sm-4">
						                		<input type="text" name="sysTemplateInfo.templateName" value="${param.templateName}" readonly="readonly" class="form-control" required placeholder="必填项" />
						                  </div>
						                  <label class="col-sm-2 control-label" >模板地址</label>
						                  <div class="col-sm-4">
						                		<input type="text" name="sysTemplateInfo.templateUrl" value="${param.templateUrl}" readonly="readonly" class="form-control" required placeholder="必填项" />
						                  </div>
							        </div>
					                <div class="form-group">
						                  <label class="col-sm-2 control-label" >生成地址</label>
						                  <div class="col-sm-4">
						                		<input type="text" name="sysTemplateInfo.codeUrl" value="${param.codeUrl}" readonly="readonly" class="form-control" required placeholder="必填项" />
						                  </div>
						                  <label class="col-sm-2 control-label" >页面名称</label>
						                  <div class="col-sm-4">
						                		<input type="text" name="sysTemplateInfo.pageName" value="${param.pageName}" readonly="readonly" class="form-control" required placeholder="必填项" />
						                  </div>
							        </div>
							        <div class="form-group">
						                  <label class="col-sm-2 control-label" >所属系统</label>
						                  <div class="col-sm-4">
						                		<input type="text"  name="sysTemplateInfo.sysName" value="${param.sysName}" readonly="readonly" class="form-control" required placeholder="必填项" />
						                  </div>
						                  <label class="col-sm-2 control-label" >所属品种</label>
						                  <div class="col-sm-4">
						                		<input type="text"  name="sysTemplateInfo.cateNo" value="${param.cateNo}" readonly="readonly" class="form-control" required placeholder="必填项" />
						                  </div>
							        </div>
							         -->
					              </div>					             
					              <!-- /.tab-pane -->
					            </div>
					            <!-- /.tab-content -->
					          </div>
					          <!-- nav-tabs-custom -->
					        </div>
			                <div class="box-footer">
				                <button type="button" class="btn btn-success pull-left" onclick="cannel('add');">取消</button>
				                <button type="button" class="btn btn-danger pull-right" onclick="add('addForm');">提 交</button>
				            </div>
						</form>
					</div>
				</div>
				<!-- /.modal-content -->
			</div>		
</div>  

<div class="modal fade" id="my_modal_edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							×
						</button>
						<h4 class="modal-title">
							<font color="red">信息修改</font> 
						</h4>
					</div>
					<div class="modal-body">
						<form class="form-horizontal" role="form" id="editForm">
							<input type="hidden" name="doCode" value="dymicSql"/>
							<input type="hidden" name="pageName"  value="sysTemplateInfo-list">
							<input type="hidden" name="formName"  value="editForm">
							<input type="hidden" id="w_templateDetailId" data-name="templateDetailId" name="sysTemplateInfo.w_templateDetailId"  value="">
							<input type="hidden" id="formToken" name="formToken" >
					        <div class="box-body" id="submitFormData_edit">
					          <!-- Custom Tabs -->
					          <div class="nav-tabs-custom">
					            <div class="tab-content">
					              <div class="tab-pane active" id="tab_1">
					              
					                <div class="form-group">
					                  <label class="col-sm-3 control-label" >标签编号</label>
					                  <div class="col-sm-8">
											<input type="text" data-name="sysTemplateInfo.tabNo" name="sysTemplateInfo.tabNo" class="form-control clean" required placeholder="必填项" />
					                  </div>
					                </div>
					                <div class="form-group">
					                  <label class="col-sm-3 control-label" >标签名称</label>
					                  <div class="col-sm-8">
										<input type="text" data-name="sysTemplateInfo.tabName" name="sysTemplateInfo.tabName" class="form-control clean" required placeholder="必填项" />
					                  </div>
					                </div>
					                <div class="form-group">
					                 <label class="col-sm-3 control-label" >每行栅格</label>
					                  <div class="col-sm-8">
										<input type="text" data-name="sysTemplateInfo.colNum" name="sysTemplateInfo.colNum" class="form-control clean" required placeholder="如：数字5或10" />
					                  </div>
					                </div>
					                
					                <!-- 
					                <div class="form-group">
					                  <label class="col-sm-2 control-label" >实体名</label>
					                  <div class="col-sm-8">
										<input type="text" id="editForm_objName" data-name="sysTemplateInfo.objName" readonly="readonly" name="sysTemplateInfo.objName" class="form-control clean" required placeholder="必填项" />
					                  </div>
					                  <div class="col-sm-2">
						                	<button type="button" class="btn btn-success btn-sm" onclick="addTabObj('editForm_objName');"><i class="fa fa-plus-circle"></i> 添加实体对象</button>
						                  </div>
					                </div>
					                
					                <div class="form-group">
					                 
					                  <label class="col-sm-2 control-label" >工程名</label>
					                  <div class="col-sm-4">
											<input type="text" data-name="sysTemplateInfo.projectName" name="sysTemplateInfo.projectName" class="form-control clean" required placeholder="必填项" />
					                  </div>
					                </div>
					                <div class="form-group">
					                  <label class="col-sm-2 control-label" >模板名称</label>
					                  <div class="col-sm-4">
											<input type="text" data-name="sysTemplateInfo.templateName" name="sysTemplateInfo.templateName" class="form-control clean" required placeholder="必填项" />
					                  </div>
					                  <label class="col-sm-2 control-label" >模板地址</label>
					                  <div class="col-sm-4">
											<input type="text" data-name="sysTemplateInfo.templateUrl" name="sysTemplateInfo.templateUrl" class="form-control clean" required placeholder="必填项" />
					                  </div>
					                </div>
					                <div class="form-group">
					                  <label class="col-sm-2 control-label" >生成地址</label>
					                  <div class="col-sm-4">
											<input type="text" data-name="sysTemplateInfo.codeUrl" name="sysTemplateInfo.codeUrl" class="form-control clean" required placeholder="必填项" />
					                  </div>
					                  <label class="col-sm-2 control-label" >页面名称</label>
					                  <div class="col-sm-4">
											<input type="text" data-name="sysTemplateInfo.pageName" name="sysTemplateInfo.pageName" class="form-control clean" required placeholder="必填项" />
					                  </div>
					                </div>
					                <div class="form-group">
					                  <label class="col-sm-2 control-label" >所属系统</label>
					                  <div class="col-sm-4">
											<input type="text" data-name="sysTemplateInfo.sysName" name="sysTemplateInfo.sysName" class="form-control clean" required placeholder="必填项" />
					                  </div>
					                  <label class="col-sm-2 control-label" >所属品种</label>
					                  <div class="col-sm-4">
											<input type="text" data-name="sysTemplateInfo.cateNo" name="sysTemplateInfo.cateNo" class="form-control clean" required placeholder="必填项" />
					                  </div>
					                </div>
					                 -->
					              </div>					             
					              <!-- /.tab-pane -->
					            </div>
					            <!-- /.tab-content -->
					          </div>
					          <!-- nav-tabs-custom -->
					        </div>
			                <div class="box-footer">
				                <button type="button" class="btn btn-success pull-left" onclick="cannel('edit');">取消</button>
				                <button type="button" class="btn btn-danger pull-right" onclick="edit('editForm');">提 交</button>
				            </div>
						</form>
					</div>
				</div>
				<!-- /.modal-content -->
			</div>		
</div>  

<div win-title="查看窗口" class="modal fade" id="my_modal_view" tabindex="-2" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog" style="width: 900px;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							×
						</button>
						<h4 class="modal-title">
							<font color="red">查看详情</font> 
						</h4>
					</div>
					<div class="modal-body">
						<form class="form-horizontal" role="form" id="viewForm">
					        <div class="box-body">
					          <!-- Custom Tabs -->
					          <div class="nav-tabs-custom">
					            <div class="tab-content">
					              <div class="tab-pane active" id="tab_1">
					              
					                <div class="form-group">
					                  <label class="col-sm-2 control-label" >编号</label>
					                  <div class="col-sm-8">
										<span data-name="tabNo"></span>
					                  </div>
					                </div>
					                
					                <div class="form-group">
					                  <label class="col-sm-2 control-label" >标签名称</label>
					                  <div class="col-sm-8">
										<span data-name="tabName"></span>
					                  </div>
					                </div>
					                
					                <div class="form-group">
					                  <label class="col-sm-2 control-label" >实体名</label>
					                  <div class="col-sm-8">
										<span data-name="objName"></span>
					                  </div>
					                </div>
					                
					                <div class="form-group">
					                  <label class="col-sm-2 control-label" >关联关系</label>
					                  <div class="col-sm-8">
										<span data-name="relation"></span>
					                  </div>
					                </div>
					                
					                <div class="form-group">
					                  <label class="col-sm-2 control-label" >表单内容</label>
					                  <div class="col-sm-8">
										<span data-name="tabContent"></span>
					                  </div>
					                </div>
					                
					                <div class="form-group">
					                  <label class="col-sm-2 control-label" >列数</label>
					                  <div class="col-sm-8">
								
									<span data-name="colNum"></span>

					                  	
					                  </div>
					                </div>
					                <div class="form-group">
					                  <label class="col-sm-2 control-label" >模板名称</label>
					                  <div class="col-sm-8">
								
									<span data-name="templateName"></span>

					                  	
					                  </div>
					                </div>
					                <div class="form-group">
					                  <label class="col-sm-2 control-label" >模板地址</label>
					                  <div class="col-sm-8">
								
									<span data-name="templateUrl"></span>

					                  	
					                  </div>
					                </div>
					                <div class="form-group">
					                  <label class="col-sm-2 control-label" >工程名</label>
					                  <div class="col-sm-8">
								
									<span data-name="projectName"></span>

					                  	
					                  </div>
					                </div>
					                <div class="form-group">
					                  <label class="col-sm-2 control-label" >生成地址</label>
					                  <div class="col-sm-8">
								
									<span data-name="codeUrl"></span>

					                  	
					                  </div>
					                </div>
					                <div class="form-group">
					                  <label class="col-sm-2 control-label" >页面名称</label>
					                  <div class="col-sm-8">
								
									<span data-name="pageName"></span>

					                  	
					                  </div>
					                </div>
					              </div>					             
					              <!-- /.tab-pane -->
					            </div>
					            <!-- /.tab-content -->
					          </div>
					          <!-- nav-tabs-custom -->
					        </div>
			                <div class="box-footer">
				                <button type="button" class="btn btn-success pull-right" onclick="cannel('view');">关闭</button>
				            </div>
						</form>
					</div>
				</div>
				<!-- /.modal-content -->
			</div>		
</div>

<div win-title="数据表对象选择窗口" class="modal fade" id="my_modal_tablebox" tabindex="-2" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog" style="margin-top:20px; width: 1200px;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							×
						</button>
						<h4 class="modal-title">
							<font color="red">数据表对象选择器</font> 
						</h4>
					</div>
					<div class="modal-body">
						<form class="form-horizontal" role="form" >
					        <div class="box-body">
					          <!-- Custom Tabs -->
					            <div class="tab-content form-group" id="tablebox_content">
					              
					              <!-- /.tab-pane -->
					            </div>
					            <!-- /.tab-content -->
					          <!-- nav-tabs-custom -->
					        </div>
			                <div class="box-footer">
			                	<button type="button" class="btn btn-danger  pull-left" onclick="checkObjNameStr();">选择完成</button>
				                <button type="button" class="btn btn-success pull-right" onclick="cannel('tablebox');">关闭</button>
				            </div>
						</form>
					</div>
				</div>
				<!-- /.modal-content -->
			</div>		
</div>

<div win-title="字段选择窗口" class="modal fade" id="my_modal_colum_checkbox" tabindex="-2" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
	<div class="modal-dialog" style="margin-top:30px; width: 1200px;">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							×
						</button>
						<h4 class="modal-title">
							<font color="red">字段选择</font> 
						</h4>
					</div>
					<div class="modal-body">
						<form class="form-horizontal" role="form" >
					        <div class="box-body">
					          <!-- Custom Tabs -->
					            <div class="tab-content form-group" id="tabs_checkbox_content">
					              
					              <!-- /.tab-pane -->
					            </div>
					            <!-- /.tab-content -->
					          <!-- nav-tabs-custom -->
					        </div>
			                <div class="box-footer">
				                <button type="button" class="btn btn-danger  pull-left" onclick="checkObjCloumStr();">选择完成</button>
				                <button type="button" class="btn btn-success pull-right" onclick="cannel('colum_checkbox');">关闭</button>
				            </div>
						</form>
					</div>
				</div>
				<!-- /.modal-content -->
			</div>		
</div>

</body>

<!-- 以下是template列表模板的模块区域 -->
<script type="text/template" id="dataList-template">
		<? for ( var i = 0; i < rows.length; i++) {?>
		<tr>
			<td><?=rows[i].tabNo?></td>
			<td><?=rows[i].tabName?></td>
			<td>
				<?=rows[i].colNum?>
			</td>
              <td>
<!--
					<button type="button" class="btn btn-success btn-xs" onclick="toLoad('<?=rows[i].templateDetailId?>','view')">查看</button>  
-->
					<button type="button" class="btn btn-warning btn-xs" onclick="toLoad('<?=rows[i].templateDetailId?>','edit');">修改</button>  
					<button type="button" class="btn btn-danger btn-xs" onclick="toDele('<?=rows[i].templateDetailId?>');">删除</button>
				</td>
		</tr>
   <?}?>  		
</script>

</html>

<!-- 以下是js模块区域 -->
<script>
var clickMenu = "template-list-instance";
var id,myPage,dataListId,searchFormId,isShowLog,tableSort,tableId;
myPage = 6;
dataListId = "dataList";
searchFormId = "searchForm";
tableSort = "sysTemplateInfo";
tableId = "templateDetailId";
isShowLog = true;

$(function () {
	//1、加载分页列表数据
	getTableData();
	//2、控制是否启用token
	//setToken();
	
	//请在下面补充其他初始化方法（如数据字典、页面加载数据等）
 });
var dateObject = $('.datepicker').datepicker( {
	language : 'zh-CN',
	//inline: true,
	todayBtn : "linked",
	format : "yyyy-mm-dd",
	autoclose: true
});
//读取（查询、编辑）数据
function toLoad(id,type){
	var paramLoadData = {"sysTemplateInfo.w_templateDetailId":id,"modelTypes":"s_"+tableSort};
	loadObj(type,paramLoadData);
}
function toDele(id){
	var index_submit = layer.confirm('您确定要删除信息吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
	, function(){
		layer.close(index_submit);
		var paramLoadData = {"modelTypes":"d_sysTemplateInfo","sysTemplateInfo.w_templateDetailId":id};
		//var paramLoadData = {"modelTypes":"u_sysTemplateInfo","sysTemplateInfo.delStatus":"T","sysTemplateInfo.w_templateDetailId":id};
		doDele(paramLoadData);
	});
}
//反显数据
function showData(type,myData){
	console.log(myData);
	if("view"==type){
		FormUtil.loadView("", myData);
		$("#my_modal_view").modal("show");
	}else if("edit"==type){
		//FormUtil.fillData("#editForm", myData,"id");
		cleanData('submitFormData_edit');//情况模态窗口内数据
		FormUtil.loadView("sysTemplateInfo", myData);
		$("#w_"+tableId).val(myData.templateDetailId);
		$("#my_modal_edit").modal("show");
	}
}

$(function () {
	$('#'+dataListId+' tbody').on('click','tr', function (e) {
	     if ( $(this).hasClass('selected') ) {
	            //$(this).removeClass('selected');
	        }
	        else {
	            $('tr.selected').removeClass('selected');
	            $(this).addClass('selected');
	        }
	     id = $('tr.selected td').eq(0).html();
	   //  console.log($('tr.selected td').eq(1).html())
	} );
	
	
  });
//加载列表数据
function getTableData(){
	deleteAllRow(dataListId);
	$.ajax({
		   type:'get',
		   url:common_list_url,
		   data:$("#"+searchFormId).serialize()+getCurrentPage(common_list_url+"?"+$("#"+searchFormId).serialize(),myPage),
		   dataType:'json',
		   success: function(myData){
		   if(isShowLog)console.log(myData);
			var data = baidu.template(dataListId+"-template",eval(myData));  
			$("#"+dataListId+"-body").html(data);
			  var option= {
					   ele:$("#"+dataListId+"-page")[0],
					   total:myData.total,
					   fn:getTableData,
					   url:common_list_url+"?"+$("#"+searchFormId).serialize()
				   }
				generatePages(option);
		   }
		});	
  }

//设置模态框隐藏事件 
$( '#my_modal_add' ).on( 'show.bs.modal' ,function(e){  
	$.ajax({
	    type:'get',
	    url:'/sendPage/token?token=true',
	    dataType:'json',
	    success: function(myData){
	    	if(isShowLog)console.log(myData);
			 $('#formToken').val(myData);
	  	}
	});	
}); 
//清空数据
function cleanData(id){
	$('#'+id).find(".clean").val("");//按照样式清空；
}
//打开添加页面
function toAdd(){
	cleanData('submitFormData');//情况模态窗口内数据
	$("#w_"+tableId).val("");
	$(".datepicker").val("");
	$('#my_modal_add').modal('show');
}

//获取对象值
function loadObj(type,paramData){
	$.ajax({
	    type:'get',
	   	url:common_info_url+"?doCode=dymicSql",
	    data: paramData,
	    async:false,
	    dataType:"json",
	    success: function(myData){
	    	showData(type,myData);
	  	}
	});	
}

//删除信息（逻辑删除）
function doDele(paramData){
	$.ajax({
	    type:"post",
	    url:common_submit_url+"?doCode=dymicSql",
	    data: paramData,
	    dataType:"json",
	    success: function(myData){
	    	var result = myData.flag;
	    	if(result=="T"){
	    		layer.alert("删除操作成功");
	    		refresh();
	    	}
	  	}
	});	
}

/**
 * 表单数据提交
 * @param formId
 */
function add(formId){
	var index_submit = layer.confirm('您确定要提交信息吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
	, function(){
		layer.close(index_submit);
		$.ajax({
		    type:"post",
		    url:common_submit_url,
		    data:$("#"+formId).serialize(),
		    dataType:"json",
		    success: function(myData){
		    	//console.log(myData);
		    	if(myData.flag=="T"){
		    		layer.alert("数据保存成功");
		    		$("#my_modal_add").modal("hide");
		    	}else{
		    		layer.alert(myData.msg);
		    	}
		    	refresh();
		  	}
		});	
	});
}

/**
 * 表单数据提交
 * @param formId
 */
function edit(formId){
	var index_submit = layer.confirm('您确定要提交信息吗？', {btn: ['Yes','No'],closeBtn: 0,offset: '220px'}
	, function(){
		layer.close(index_submit);
		$.ajax({
		    type:"post",
		    url:common_submit_url,
		    data:$("#"+formId).serialize(),
		    dataType:"json",
		    success: function(myData){
		    	//console.log(myData);
		    	if(myData.flag=="T"){
		    		layer.alert("数据保存成功");
		    		$("#my_modal_edit").modal("hide");
		    	}else{
		    		layer.alert(myData.msg);
		    	}
		    	refresh();
		  	}
		});	
	});
}

//关闭win
function cannel(type){
	if(strUtil.isNull(type)){
		$('#my_modal_add').modal('hide');
	}else{
		$('#my_modal_'+type).modal('hide');
	}
}

function refresh(){
	getTableData();
}


function setToken(){
	$.ajax({
	    type:'get',
	    url:'/sendPage/token?token=true',
	    dataType:'text',
	    success: function(myData){
	    	console.log(myData);
			 $('#formToken').val(myData);
	  	}
	});	
}

var objNameId = "";
function addTabObj(objId){
	var tableAttr = "";
	objNameId = objId;
	//控制二次选择 或者修改时方便反显
	var objNameVal = $("#"+objId).val();
	var objNameMap = {};
	if(!strUtil.isNull(objNameVal)){
		var objNamesss = objNameVal.split(",");
		for(var a=0;a<objNamesss.length;a++){
			objNameMap[objNamesss[a]]=objNamesss[a];
		}
	}
	var objs = $("#tablebox_content");
	objs.html("");
	var index_load = layer.msg("数据正在加载中。。。", {shade: false,offset: '220px'});
	$.ajax({
	    type:'get',
	   	url:common_list_url,
	    data: {"doCode":"dymicSql","modelTypes":"s_sortInfo","sortInfo.w_sortStatus":"1","orderBy":"info_table_name"},
	    async:false,
	    dataType:"json",
	    success: function(myData){
	    	console.log(myData);
	    	for(var i=0;i<myData.rows.length;i++){
	    		var obj = myData.rows[i];
	    		var valStr = "";
	    		var valTitle = "";
	    		var checclass="";
	    		if(!strUtil.isNull(obj.objName)){
	    			valStr = obj.infoTableName;
	    			valTitle = "对象名（"+obj.objName+"），描述（"+obj.sortName+"），表名（"+obj.infoTableName+"）";
		    		if(objNameMap[obj.objName]){
		    			checclass=" checked='checked' ";
		    		}
	    		}else{
	    			valStr = "不可用";
	    			checclass="disabled='disabled'";
	    			valTitle = "表（"+obj.infoTableName+"）未定义objName";
	    		}
	    		valStr += "-"+obj.sortName;
	    		tableAttr += "<span title='"+valTitle+"' class='col-sm-3 span-c'>";
	    		tableAttr += "<input "+checclass+" name='sortInfoTableName' infoTableName='"+obj.infoTableName+"' sortCode='"+obj.sortCode+"' value='"+obj.objName+"' type='checkbox'/> "+(i+1)+"."+strUtil.subStr(valStr,20);
	    		tableAttr += "</span>";
	    	}
	    	layer.close(index_load);
	    	objs.html(tableAttr);
	    	$("#my_modal_tablebox").modal("show");
	  	}
	});
}
var objNameStr ,sortCodeStr;
var sortCodeMap = {};
function checkObjNameStr(){
	objNameStr = "";
	sortCodeStr = "";
	sortCodeMap = {};
	$("input[name='sortInfoTableName']:checked").each(function(){
		objNameStr +=$(this).val()+",";
		sortCodeStr +=$(this).attr("sortcode")+",";
		sortCodeMap[$(this).attr("sortcode")]=$(this).val();
	});
	objNameStr=objNameStr.substring(0,objNameStr.length-1);
	sortCodeStr=sortCodeStr.substring(0,sortCodeStr.length-1);
	if(strUtil.isNull(objNameStr)){
		layer.alert("未选中对象");
		return;
	}
	$("#"+objNameId).val(objNameStr);
	$("#my_modal_tablebox").modal("hide");
}


function addTabObjColum(tabContentId,objNameId){
	var tabContentVal = $("#"+tabContentId).val();
	//alert(objNameVal+"--"+tabContentVal);
	if(strUtil.isNull(sortCodeStr)){
		layer.alert("请先选择实体名");
		$("#objNameId").focus();
		return;
	}else{
		var index_load = layer.msg("数据正在加载中。。。", {shade: false,offset: '220px'});
		
		var sortCodeArr = sortCodeStr.split(",");
		var tabTitleHtml = "",tabContentHtml="";
		var tabTobj = $("#tabs_checkbox");
		var tabTobjContent = $("#tabs_checkbox_content");
		
		tabTobjContent.html("");
		for(var i=0;i<sortCodeArr.length;i++){
			var sortCode = sortCodeArr[i];
			var objName = sortCodeMap[sortCode];
			tabContentHtml +="<div class='col-sm-3'><div class='box box-danger'><div class='box-body'>";
			tabContentHtml +="<h2 class='col-sm-12 btn btn-success btn-lg'>第"+(i+1)+"个"+objName+"</h2>";
			tabContentHtml +=getTableAttr(objName,sortCode);
			tabContentHtml +="</div></div></div>";
		}
     
		//tabTobj.html(tabTitleHtml);
		tabTobjContent.html(tabContentHtml);
		
		layer.close(index_load);
		$("#my_modal_colum_checkbox").modal("show");
	}
	
	//showCheckBox();
}
function getTableAttr(objName,sortCode){
	var tableAttr = "";
	$.ajax({
	    type:'get',
	   	url:common_list_url,
	    data: {"doCode":"dymicSql","modelTypes":"s_metadata","orderBy":"data_attr","metadata.w_sortId":sortCode},
	    async:false,
	    dataType:"json",
	    success: function(myData){
	    	for(var i=0;i<myData.rows.length;i++){
	    		var obj = myData.rows[i];
	    		var valStr = obj.dataAttr+"->"+obj.dataFullName;
	    		tableAttr += "<span title='"+valStr+"' class='col-sm-12 span-c'><input name='objnamecloumcheckbox' value='"+objName+"."+obj.dataAttr+"' type='checkbox'/> "+(i+1)+"."+strUtil.subStr(valStr,15)+"</span>";
	    	}
	  	}
	});
	return tableAttr;	
}
function checkObjCloumStr(){
	var objCloumStr = "";
	$("input[name='objnamecloumcheckbox']:checked").each(function(){
		objCloumStr +=$(this).val()+",";
	});
	objCloumStr=objCloumStr.substring(0,objCloumStr.length-1);
	if(strUtil.isNull(objCloumStr)){
		layer.alert("未选中字段");
		return;
	}
	$("#addForm_tabContent").val(objCloumStr);
	$("#my_modal_colum_checkbox").modal("hide");
}
</script>



